﻿using Medicine.Entity;
using Medicine.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Medicine
{
    public partial class AddMedicine : Form
    {
        private MedicineServie ms = new MedicineServie();
        public AddMedicine()
        {
            InitializeComponent();
        }

        private void AddMedicine_Load(object sender, EventArgs e)
        {

        }
        //添加商品
        private void button1_Click(object sender, EventArgs e)
        {
            Medicin m = new Medicin();
            m.Name = this.textBox1.Text.Trim();
            try
            {
                m.Price = float.Parse(this.textBox2.Text.Trim());
            }
            catch (Exception c)
            {
                m.Price = 0;
            }
            m.Information = this.richTextBox1.Text.Trim();
            if (this.checkBox1.Checked == false)
                m.Ison = 0;
            else
                m.Ison = 1;
            if (m.Name != "" && m.Information != "")
            {
                ms.insert(m);
                this.Close();
            }
            else
                MessageBox.Show("信息没填完");
        }
    }
}
